<template>
  <div class="main">
    <div class="user_msg">
      <a href class="main-header-logo">
        <img :src="show.header.logo" alt />
        <span>我爱报销</span>
      </a>
      <div class="user_nameimg">
        <van-image round :src="photo" @click="editPhpto" />
        <span class="nickname">
          {{nickname}}
          <ul class="cz_list">
            <li @click="$router.push('/authentication')">实名认证</li>
            <li @click="$router.push('/edituserinfo')">修改资料</li>
            <li @click="$router.push('/edituserphone')">修改手机号码</li>
            <li @click="$router.push('/edituserpassword')">修改密码</li>
            <li @click="logOut">退出账号</li>
          </ul>
        </span>
      </div>
      <div class="user_money shou" @click="$router.push('/replace/mybalance')">
        我的余额
        <span class="money_num">{{show.header.coin}}</span>
      </div>
    </div>
    <div class="maxdiv">
      <div class="top_main">
        <span @click="topClick(item)" v-for="(item,index) in show.header.typeList" :key="index" :class="show.header.showTitle==item.title?'clicked_top top_main_list':'top_main_list'">{{item.title+'('+item.num+')'}}</span>
      </div>
        <el-input style="width:280px;margin-left:30px" placeholder="请输入" class="search" v-model.trim="show.search.searchData" clearable>
        <i slot="prefix" class="el-input__icon el-icon-search"></i>
        <el-button slot="append" @click="searchBtn">搜索</el-button>
        </el-input>
        <el-radio v-model="show.search.searchType" label="order_number" style="margin-left:20px">订单编号</el-radio>
        <el-radio v-model="show.search.searchType" label="rmb_voucher">报销凭证号</el-radio>
        <!-- 添加 -->
        <div style="padding:0 30px;margin-top:30px">
          <el-table 
            :data="online.dataList" 
            border 
            style="width: 100%" 
            @row-click="goDetails" 
            v-loading='show.tabload'
            element-loading-text="加载中..."
            @sort-change="tabchange"
          >
          <el-table-column type="index" label="#"></el-table-column>
          <el-table-column prop="order_number"  label="订单编号" ></el-table-column>
          <el-table-column prop="service_project_title"  label="代办事项" width="120"></el-table-column>
          <el-table-column  label="报销类型" width="100">
            <template slot-scope="scope">
              {{scope.row.expenseCate_title}}
            </template>
          </el-table-column>
          <el-table-column label="签字文件" v-show="show.args.type!=1 && show.process.xm == 3" width="90">
            <template slot-scope="scope" v-if="scope.row.sign_file">
              <el-button @click.stop="download" type="text">
                <a class="f20" style="color:#4259f0" :href="scope.row.sign_file" :download="scope.row.sign_file"><van-icon name="records" class="f20" /></a>
              </el-button>
            </template>
          </el-table-column>
          <el-table-column label="OA截图" v-show="show.args.type!=1" width="90">
            <template slot-scope="scope" v-if="scope.row.oa_img">
              <el-button @click.stop="download" type="text">
                <a class="f20" style="color:#4259f0" :href="scope.row.oa_img" :download="scope.row.oa_img"><van-icon name="photo" /></a>
              </el-button>
            </template>
          </el-table-column>    
          <el-table-column  label="报销时间(天)" width='120'>
            <template slot-scope="scope">
              <span>{{scope.row.service_time == 0?'NA':scope.row.service_time}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="surplus_time" label="剩余天数(天)" sortable='custom' v-if="show.args.type==2" width="150"> 
            <template slot-scope="scope">
              <span v-if='scope.row.expenseCate_id != 1'>
                {{Math.floor((((scope.row.service_time*1000 * 3600 * 24) + (new Date(scope.row.created_at).getTime()))-(new Date().getTime()))/(1000*3600*24))<0?'发票已经过期': Math.floor((((scope.row.service_time*1000 * 3600 * 24) + (new Date(scope.row.created_at).getTime()))-(new Date().getTime()))/(1000*3600*24))}}
              </span>
              <span v-else>专利案件时间冻结</span>
            </template>
          </el-table-column>
          <el-table-column prop="created_at"  label="创建时间" sortable='custom' width='160'>
            <template slot-scope="scope">
              <span>{{scope.row.created_at}}</span>
            </template>
          </el-table-column> 
          <el-table-column prop="updated_at"  label="更新时间" sortable='custom' v-if="show.args.type!=1" width='160'>
            <template slot-scope="scope">
              <span>{{scope.row.updated_at}}</span>
            </template>
          </el-table-column>
          <el-table-column  label="状态" width="100">
            <template slot-scope="scope">
              <span :class="scope.row.status | statusColor">{{scope.row.status_title}}</span>
            </template>
          </el-table-column>
          <el-table-column  label="订单资料审核" v-if="show.args.type==2">
            <template slot-scope="scope">
              <el-button v-if="scope.row.status==10" size="mini" type="primary" @click.stop="reviewOrder(scope.row.id)">审核</el-button>
              <span v-else-if="scope.row.status==11" style="color:#74b9ff">等待用户补充信息<el-button size="mini" type="primary" @click.stop="supplementOrder(scope.row.id)">补充信息</el-button></span>
              <span v-else-if="scope.row.status== 3" style="color:#145cad">订单完成 等待用户确认</span>
              <span v-else-if="scope.row.status== 2" style="color: #14ad60">审核通过 处理中</span> 
              <span v-else-if="scope.row.status== 13">退款中<span v-if="scope.row.isExamine==1">(已审核)</span><span v-else>(未审核)</span> </span>    
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-pagination
        style="margin:10px 30px"
        @current-change="handleCurrentChange"
        :current-page="show.args.p"
        :page-size="10"
        layout="total,prev, pager, next, jumper"
        :total='show.dataCount'>
      </el-pagination>
      <!-- 订单详情 -->
      <el-dialog
        style="text-align: center;z-index:2000"
        :visible.sync="show.detailDialog"
        width="35%"
        :show-close="true"
      >
        <div class="orderInfo">
        <div class="nav-bar">
        <div class="bottom">{{online.detailData.order_number}}
              </div>
            </div>
            <div class="orderInfo-content">
              <van-collapse v-model="show.activeClass" style="padding-bottom:40px">
                <van-collapse-item title="流程进度" name="1" v-if="online.detailData.status != 1">
                  <div class="steps_box" v-for="(data, index) in online.detailData.statuss" :key="index">
                    <span class="outside">
                      <span class="inside"></span>
                    </span>
                    <span>
                      <div>{{data.describe}}</div>
                      <div>{{data.created_at}}</div>
                    </span>
                  </div>
                </van-collapse-item>
                <van-collapse-item title="订单信息" name="2">
                  <van-cell :border="false" title="订单状态" :value="online.detailData.statusName" />
                  <van-cell :border="false" title="状态详情" :value="show.ddStatus" />
                  <van-cell :border="false" title="代办事项" :value="online.detailData.service_project_title" />
                  <van-cell :border="false" title="报销类型" :value="online.detailData.expenseCate_title" />
                  <van-collapse-item
                    title="报销补充信息"
                    name="4"
                  > 
                    <van-cell :border="false" :title="item.fieldCh" v-for="(item,index) in ordermsg2[1]" :key="index" :value="item | fs" v-if='item.fieldEn != "money"'/>
                  </van-collapse-item>
                  <van-cell :border="false" title="退回原因" v-if="online.detailData.order_records_reason"  :value="online.detailData.order_records_reason['isSelf']==1?'代报员原因':'客户原因'" />
                  <van-cell
                    v-if="online.detailData.order_records_reason"
                    :border="false"
                    title="原因说明"
                    label-class="font_danger ml10" 
                  >
                    <template #default>
                      <span>{{online.detailData.order_records_reason.remark}}</span>
                    </template>
                  </van-cell>
                  <van-cell :border="false" title="创建时间" :value="online.detailData.created_at" />
                  <van-cell :border="false" v-if="online.detailData.status==2" title="接单时间" :value="show.jdDate" />
                  <van-cell :border="false" title="报销时间" :value="online.detailData.service_time == 0?'NA':online.detailData.service_time + '天'" />
                  <van-cell :border="false" title="发票是否过期" :value="online.detailData.service_time == 0 ?'是':'否'" />
                  <van-cell :border="false" title="预期收益" :value="online.detailData.quoted_price+'元'" /> 
                  <van-cell
                    :border="false"
                    title="报销人姓名"
                    :value="online.detailData.expenseName"
                    v-if="online.detailData.expenseName"
                    
                  />
                  <van-cell
                    :border="false"
                    title="联系电话"
                    :value="online.detailData.users_phone"
                  />
                  <van-cell :border="false" title="OA账号" :value="online.detailData['expand_info as users_oa_phone']" v-if="online.detailData.status != 1" />
                  <van-cell :border="false" title="OA密码" :value="online.detailData['expand_info as users_oa_pwd']" v-if="online.detailData.status != 1" />
                  <van-cell v-for="(item,index) in ordermsg2[0]" :key="index" :title="item.fieldCh" :border="false">
                    <template #default>
                      <a
                        v-if='!Array.isArray(item.value)'
                        class="f20 btn_text"
                        :href="item.value"
                        target="_blank"
                      >
                      <van-icon name="balance-list-o" />
                    </a>
                    <span v-else v-for='(img,index1) in item.value' :key='index1' >
                      <a
                        class="f20 btn_text"
                        :href="img"
                        target="_blank"
                      >
                        <van-icon name="balance-list-o" />
                      </a>
                    </span>
                    </template>
                  </van-cell>

                  <van-cell title="签字文件" v-if="this.show.process.bz != 0 && this.show.process.xm != 4">
                    <template #default>
                      <a
                        class="file-details f20 btn_text"
                        :href="online.detailData.sign_file"
                        download="orderFile/20200906/pkq.jpeg"
                      >
                        <van-icon name="records" class="f20" />
                      </a>
                    </template>
                  </van-cell>
                  <van-cell
                    title="OA截图"
                    v-if="(this.show.process.bz != 0 && this.show.process.bz != 1 )"
                  >
                    <template #default>
                      <a
                        class="file-details f20 btn_text"
                        :href="online.detailData.oa_img"
                        download="orderFile/20200906/pkq.jpeg"
                      >
                        <van-icon name="photo" />
                      </a>
                    </template>
                  </van-cell>
                  <van-cell
                    title="报销凭证号"
                    v-if="(this.show.process.bz != 0 && this.show.process.bz != 1 &&  this.show.process.bz != 2)"
                  >{{online.detailData.rmb_voucher}}</van-cell>
                </van-collapse-item>
              </van-collapse>
            </div>
            <div class="order_jiebtn order_btn" v-if="online.detailData.status==1">
              <div @click="pickOrder">接单</div>
            </div>
            <!-- 已接单 -->
            <div class="order_qxbtn order_btn">
              <!-- 撤回 -->
              <div class="order_backbtn order_btn" v-if="(this.show.process.lx == 2 && this.show.process.bz == 0) || this.show.process.lx == 2 &&((this.show.process.xm==4 && this.show.process.bz == 1 ))" @click="show.showback=true">退回订单</div>
              <div @click="withdrawFile('qz')" v-if="this.show.process.lx == 2 && (this.show.process.xm == 3 && this.show.process.bz == 1) && online.detailData.status == 2" class="withdraw-btn">撤回签字文件</div>
              <div @click="withdrawFile('oa')" v-if="((this.show.process.xm==3 && this.show.process.bz == 2) || (this.show.process.xm == 4 && this.show.process.bz == 2)) && online.detailData.status == 2">撤回上传oa截图</div>
              <div @click="withdrawFile('card')" v-if="online.detailData.status == 12" class="withdraw-btn">撤回报销凭证号</div>
              <div @click="upFile" v-if="this.show.process.bz == 0 && this.show.process.lx == 2 && this.show.process.xm == 3">上传签字文件</div>
              <div @click="upFile" v-if="this.show.process.lx == 2 && ((this.show.process.xm==3 && this.show.process.bz == 1) || (this.show.process.xm == 4 && this.show.process.bz == 0))">上传OA截图</div>
              <div @click="upFile" v-if="this.show.process.lx == 2 && ((this.show.process.xm==3 && this.show.process.bz == 2) || (this.show.process.xm == 4 && this.show.process.bz == 2))">填写报销凭证号</div>
              <div @click="truebc" v-if="online.detailData.status == 12">确认订单</div>
            </div>
            <!-- 
                    1   待接单
                    2   已接单
                    3   用户待确认
                    4   已完成
                    5   用户待缴费
            -->
          </div>
        </el-dialog>
        <!-- 上传文件 -->
        <el-dialog
          :title="this.show.process.title"
          style="text-align: center;"
          :visible.sync="show.showUpFile"
          width="35%"
          :show-close="true"
        >
        <el-row :gutter="40">
          <el-col :span="24" style="display: flex;justify-content: center;">
            <div class="upload-wrap">
            <i class="el-icon-circle-close" style="position:absolute;top:5px;right:5px;z-index:99;font-size:20px;cursor:pointer" v-if="show.imgList.imageUrl" @click="delImg"></i>
            <el-image  style="width: 150px; height: 150px" :src="show.imgList.imageUrl" :preview-src-list="show.imgList.srcList" v-if="show.imgList.imageUrl" >
            </el-image>
            <el-upload
              v-else
              class="avatar-uploader"
              action="http://v1-e.xgwl.net.cn/v1000_upload"
              :http-request="uploadFileHttp"
              :on-progress="handleProgress"
              :on-success="handleSuccess"
              :show-file-list="false">
              <i class="el-icon-plus avatar-uploader-icon"></i>
            </el-upload>
            </div>
          </el-col>  
        </el-row>
        <div class="supplement-btn">
          <van-button round block type="info" native-type="submit" @click="onSubmit">提交</van-button>
        </div>
        </el-dialog>
        <!-- 报销凭证号 -->
        <el-dialog
          title="填写报销凭证号"
          style="text-align: center;"
          :visible.sync="show.showbxnum"
          width="35%"
          :show-close="true"
          @close="handleBXClose"
        >
        <!-- @close="show.showbxnum=false" -->
          <van-cell-group>
              <van-field  class="van-field-isRequired" v-model="show.rmb_voucher" label="报销凭证号" placeholder="请输入报销凭证号" />
          </van-cell-group>
          <div class="supplement-btn">
              <van-button round block type="info" native-type="submit" @click="onSubmitBx">提交</van-button>
          </div>
        </el-dialog>
        <!-- 退回订单 -->
        <el-dialog
          title="退回订单"
          style="text-align: center;"
          :visible.sync="show.showback"
          width="35%"
          :show-close="true"
          @close="show.showback=false"
        >
        <el-form>
          <el-form-item label="退回理由">
              <el-input type="textarea" v-model="show.order_sign.backvalue"  placeholder="请输入退回理由(最多100字)" maxlength="100" ></el-input>
          </el-form-item>
        </el-form>
        <div class="supplement-btn">
            <van-button round block type="info" native-type="submit" @click="onSubmitBack">确定退回</van-button>
        </div>
        </el-dialog>
        <!-- 订单资料第一次审核 -->
        <el-dialog
          title="订单资料审核"
          style="text-align:center"
          :visible.sync="show.reviewDialog"
          width="45%"
          :show-close="true"
          @close="show.reviewDialog=false"
        >
            <van-collapse v-model="action.activeClass">
      <van-collapse-item title="订单信息" name="1">
        <div class="order-info">
          <van-field
            readonly
            label="报销地点"
            :value="show.order.company_title"
          />
          <van-field
            readonly
            label="待办事项"
            :value="show.order.service_project_title"
          />
          <van-field
            readonly
            label="报销类型"
            :value="show.order.expenseCate_title"
          />
          <van-field
            readonly
            label="报销时间"
            :value="show.order.service_time==0?'NA':show.order.service_time+'天'"
          />
          <van-field
            readonly
            label="发票是否过期"
            :value="show.order.isTimeOver==-1?'否':'是'"
          />
        </div>
      </van-collapse-item>
      <van-collapse-item title="订单资料" name="2">
       <div class="order-data">
          <div class="order-data-item" v-for='(item,index) in show.oldJson' :key='index'>
            <van-cell  required>
                <template #title>
                  <span class="custom-title">{{item.fieldCh}}</span>
                   <van-tag type="danger" v-if="item._child && item.isSure == '-1' && item.needExamineDataNotPass" @click="reasonListShows(item.needExamineDataNotPass)" class="reason-bottom" style="margin-left:10px">{{'退回原因('+item.needExamineDataNotPass.length+')'}}</van-tag>
                </template>
              <template #default>
                <van-tag  :type="item.colour" 
                @click='showChoose(index)'>{{item.title}}</van-tag>
              </template>
            </van-cell>
            <div class='img-choose-warp' v-if="item._child">
              <div class='img-choose flex-column' v-for='(value,key) in item._child' :key='key'>
              <van-image fit='cover' width="80" height="80" :src='value.value' @click='getBigImg(value.value)'>
                  <template v-slot:error>
                    <img src="../../../../assets/img/pdf.png" :href="value.value" class="error-img" @click="pdfLocation(value.value)" />
                  </template>
              </van-image>
              <van-radio-group v-model="value.isSure" @change="radioChange(index,key)" >
                <van-radio name="1" class="mt5" >通过</van-radio>
                <van-radio name="-1" >不通过</van-radio>
              </van-radio-group>
              <van-tag type="danger" v-if="value.needExamineDataNotPass && value.isSure == '-1'" @click="reasonListShows(value.needExamineDataNotPass)" class="reason-bottom">{{'退回原因('+value.needExamineDataNotPass.length+')'}}</van-tag>
              </div>
            </div>
            <div class='img-choose-warp' v-if="item.value">
              <div class='img-choose flex-column'>
              <van-image fit='cover' width="80" height="80" :src='item.value' @click='getBigImg(item.value)'>
               <template v-slot:error>
                  <img src="../../../../assets/img/pdf.png" :href="item.value" class="error-img" @click="pdfLocation(item.value)" />
                </template>
              </van-image>
              <van-radio-group v-model="item.isSure" @change="radioChange(index)" >
                <van-radio name="1" class="mt5" >通过</van-radio>
                <van-radio name="-1" >不通过</van-radio>
              </van-radio-group>
                 <van-tag type="danger" v-if="item.needExamineDataNotPass && item.isSure == '-1'" @click="reasonListShows(item.needExamineDataNotPass)" class="reason-bottom">{{'退回原因('+item.needExamineDataNotPass.length+')'}}</van-tag>
              </div>
            </div>
          </div>
        </div>
      </van-collapse-item>
      <div class="supplement-button">
      <van-button round block type="danger" @click="action.isShowReturn=true" style='margin-bottom:30px;'>退回订单</van-button>
      <van-button round block type="info" native-type="submit" @click="Auditinfo">提交</van-button>
    </div>
    </van-collapse>
        </el-dialog>
      </div>
    <editAvatar ref="editAvatar" />
    <bigImg :url="show.imgList.bigImgUrl" :size="'50%'" :isShow="show.imgList.showBigImg" @close="show.imgList.showBigImg=false"></bigImg>
    <!-- 弹出层 -->
       <van-popup v-model="action.isShowPopup" position="bottom" :style="{ height: '30%' }">
      <van-picker
        show-toolbar
        style=" border: 1px solid #ddd;"
        default-index="0"
        :columns="show.columns"
        @confirm="onConfirm"
        @cancel="onCancel"
        />
    </van-popup>
    <!-- dialog -->
     <el-dialog
      title="图片审核"
      :visible.sync="show.dialogs"
      width="35%"
      center>
      <el-dialog width="30%" title="确定取消吗" :visible.sync="show.child_dialogs" append-to-body center>
        <span>你确定取消该操作吗？确认之后该图片会改为通过</span>
        <div class="btn-wrap">
        <el-button @click="show.dialogs = true;show.child_dialogs=false">取 消</el-button>
        <el-button type="primary"  @click="examineCancel">确 定</el-button>
        </div>
      </el-dialog>
      <div class="dialog column">
        <div class="dialog-title">{{show.selectColumn?show.reasonData.fieldCh:show.reasonData.fieldCh+' 图片'+show.reasonData.picNo}}</div>  
        <!-- 图片展示及按钮 -->
        <div class="dialog-img">
          <img :src="show.reasonData.value" @click='getBigImg(show.reasonData.value)' v-if="!show.selectColumn"> 
        </div>
        <!-- 选择框 -->
      <el-select v-model="show.reasonClickList" :value="show.reasonClickList"  multiple placeholder="请选择" :multiple-limit="8"  popper-class="select" @change="handleChange" value-key="id"  ref="mySelect" @blur="selectBlur" @focus="selectFocus"> 
      <el-option
        v-for="item in show.reasonList"
        :key="item.id"
        :label="item.title"
        :value="item"
      />
      </el-select>
        <!-- 如果文本 文字统计 -->
        <van-field
          style="border: 1px solid #f2f2f2;margin-top:10px;padding:50px 0;"
          v-model="show.message"
          v-show="show.reasonData.isCheck"
          ref="textareas"
          rows="2"
          autosize
          type="textarea"
          maxlength="20"
          placeholder="请输入原因"
          show-word-limit
        >
         <template #button>
            <van-tag type="danger" @click="reasonMsg" style="white-space:nowrap;position: absolute;bottom: -5px;right: 5px;">完成</van-tag>
         </template>
        </van-field>
        <div class="btn-wrap">
        <el-button @click="show.dialogs = false;show.child_dialogs = true">取 消</el-button>
        <el-button @click="onBeforeClose('confirm')">确 定</el-button>
        </div>
      </div>
   </el-dialog>
   <!-- 审核 不通过原因 弹出层 -->
       <el-dialog :visible.sync="show.isReasonListShow" title="不通过原因" center>
      <div class="column" style="padding-top:10px;">
        <span v-for="(item,index) in show.reasonListDialog" :key="index" style="padding:5px 16px;font-weight:200;font-size:14px;">{{(index+1)+'. '+item.title}}</span>
      </div>    
    </el-dialog>
      <van-dialog v-model="show.order_sign.userSign" title="用户退单审核" v-if="online.detailData.status == 13 && online.detailData.ordersRefunds_status == 1" :before-close="applySign">
      <div class="column" style="padding:10px 16px">
        <span style="font-size:15px;text-align:center"><font style="font-weight:bold">用户退单原因：</font> {{online.detailData.ordersRefunds_applyRemark}}</span>
          <van-radio-group v-model="show.order_sign.isSign" direction="horizontal" style="padding:10px 0">
            <van-radio :name=1 icon-size="18px">通过</van-radio>
            <van-radio :name=-1 icon-size="18px">不通过</van-radio>
          </van-radio-group>
            <el-input type="textarea" v-model="show.order_sign.msg" v-show="show.order_sign.isSign == -1" placeholder="请输入原因" rows=4 ></el-input>
      </div>
    </van-dialog>
    <!-- adminSign -->
    <van-dialog v-model="show.adminSign" title="退单申请" show-cancel-button :before-close="signReason">
       <div class="column" style="padding:10px 16px">
       <van-field
        v-model="show.message1"
        rows="2"
        autosize
        type="textarea"
        maxlength="50"
        placeholder="请输入退单原因"
        show-word-limit
      />
       </div>
    </van-dialog>

    <van-dialog v-model="action.isShowReturn" title="退回原因" show-cancel-button @confirm='ReturnOrder' @close='closeReturnOrder'>
       <div class="column" style="padding:10px 16px">
       <van-field
        v-model="post.remark"
        autosize
        placeholder="请输入退回原因"
        show-word-limit/>
       </div>
    </van-dialog>
    <!-- 代报员补充资料模块 -->
  <SupplementOrder :id='action.supplementOrderId' :isSupplementOrder='this.action.isSupplementOrder' :supplementOrderClose='supplementOrderClose'></SupplementOrder>
  </div>
</template>
<script>
import { getMyInfo } from "@a/user.js";
import { Message } from 'element-ui';
import editAvatar from "@cm/edit-avatar.vue";
import { Dialog,Toast,FieldRadioGroup, Radio,Picker,Popup } from "vant";
import {get} from "../../../../api/query"
import bigImg from "../../../../components_basics/bigImg.vue"
import SupplementOrder from './fileAddPage.vue'
import Axios from 'axios';
import config from '../../../../api/config'
export default {
  components: {
    editAvatar,
    bigImg,
    SupplementOrder
  },
  data() {
    return {
      // 用作展示的数据
      online:{
        needJson:[],
        dataList: [],   //总数据
        detailData: {    //单条数据详情
          order_number: "",
          statuss: [],
         statusName:'',       //当前状态名字
        },
      },
      action: {
        isSupplementOrder:false,  // 代报员补充资料弹框
        supplementOrderId: 1,  //  代报员补充资料id
        activeClass:['1','2'],
        isShowPopup:false,
        //记住点击的弹出层
        clickIndex:'',
        isShowReturn:false,
      },
      show: {
        baseUrls: process.env.VUE_APP_BASE_URL,  //测试环境路径
        //头部一些默认样式
        header:{ 
          logo: require("@/assets/img/logo.png"),    //logo图片
          showTitle:'待接单',  //头部默认选择
          typeList:[            //头部列表
            {title:'待接单',num:0,type:1},
            {title:'未完成',num:0,type:2},
            {title:'已完成',num:0,type:3},
          ],
          coin:'',        //钱包金额
        },
        // 搜索选项
        search:{
          searchData:"",   //搜索框
          searchType:'order_number',     // 搜索选项
        },
        args:{
          p:1,    //页码
          limit:10,   //每页的数量
          type:1,     //类型
          sort_str:'', //根据哪个字段排序
          sort_order:'',     //升序或者降序
          order_number:'',  //订单号
          rmb_voucher:''    //报销凭证号
        },
        activeClass: ["1", "2"],    //折叠面板
        jdDate: "",     //接单时间
        detailDialog:false,  //展示详情
        reviewDialog:false,  //订单审核是否展示
        tabload:false,       //表格加载动画
        dataCount :0,        //订单总条数 
        imgList:{
          bigImgUrl:"",        //大图预览 url
          imageUrl: '',        //大图预览前的url
          srcList:[],          //图片预览列表
          showBigImg:false,    //是否展示大图 
        },
        showback:false,      //退回订单按钮
        showbxnum:false,     //是否显示填写报销凭证号
        rmb_voucher:'',      //报销凭证号
        showUpFile:false,    //是否展示上传文件
        ddStatus:'',          //状态详情
        process:{
          bz:0,            //步骤
          wh:0,            //上传什么东西
          title:'',       //提示语
          lx:0,          //订单状态
          xm:0           //代办事项(签字？m )
        },
        // 退单
        order_sign:{
          userSign:true,
          isSign:null,
          msg:'',
          backvalue:'',      
        },
        fileList: [],        //上传文件列表
        isReasonListShow:false,  //原因是否显示
        reasonListDialog:[],
        order:{},
        oldJson:[
          {
            fieldEn:'',
            value:'',
            isSure:'',
          },
          {
            fieldEn:'',
            isSure:'',
            _child:[
              {value:'',isSure:true,},
              {value:'',isSure:true,},
            ]
          }
        ],
        columns: ['通过','不通过'],
        dialogs:false,     //是否显示弹出框
        child_dialogs:false,
        message:'',       //填写原因内容
        reasonList:[{     //select列表
          title:'',
          id:'' 
        }],
        order_detail:{},
        reasonClickList:[],  //多选后的数据
        reasonData:{         //不通过原因 图片详细信息
          title:'',           //标题
          picNo:'',          //图片序号，picNo
          reason:[],         //原因
          fieldEn:'',       //英文名字
          isCheck:false,    //switch开关
          indexs:['parentIndex','childIndex'],         //不通过原因的索引[主，子]
        },
        selectColumn:false,
        params:{}
      },
      post:{
        id:''  ,
        remark:''
      }
    };
  },

  methods: {
    //
    closeReturnOrder(){
      this.post.remark = '';
    },
    // 审核时 订单退回
    ReturnOrder(){
       if (this.post.remark.trim().length == 0) {
        Toast.fail("请输入退单原因");
      } else {
        let params = {
          id: this.post.id,
          remark: this.post.remark
        };
        get("applyChargeback", params, res => {
          if (res.code == 200) {
            Toast.success("退回成功");
            this.post.remark = '';
            this.getData() 
            this.action.isShowReturn = false;
            this.show.reviewDialog = false;
          }
        });
      }
    },
    /*
    代报员补充资料模块
    */
    supplementOrder(id){
      this.action.isSupplementOrder = true;
      this.action.supplementOrderId = id
    },
    supplementOrderClose(){
      this.action.isSupplementOrder = false;
      this.getData()
    },
    /*
    订单审核模块
    */
    // 审核提交1
    Auditinfo(){
    let isOK=true;
      for(var i=0;i<this.show.oldJson.length;i++){
        if(this.show.oldJson[i]._child){
          for(var h=0;h<this.show.oldJson[i]._child.length;h++){
            if(this.show.oldJson[i]._child[h].isSure==0){
              Message.error('请选择'+this.show.oldJson[i].fieldCh);return
            }
          }
        }else{
          if(this.show.oldJson[i].isSure==0){
            Message.error('请选择'+this.show.oldJson[i].fieldCh);return
          }
        }
      }
      let sendJson=[]
      let type=1
      this.show.oldJson.map((v)=>{
        if(v.isSure==-1){
          type=-1
        }
        if(v._child){
          let _child=[]
          v._child.map((val)=>{
            val.needExamineDataNotPass == undefined? _child.push({value:val.value,isSure:val.isSure}): _child.push({value:val.value,isSure:val.isSure,needExamineDataNotPass:val.needExamineDataNotPass})
          })
          v.needExamineDataNotPass == undefined ?sendJson.push({fieldEn:v.fieldEn,isSure:v.isSure,_child:_child}):sendJson.push({fieldEn:v.fieldEn,isSure:v.isSure,needExamineDataNotPass:v.needExamineDataNotPass,_child:_child})
        }else{
          v.needExamineDataNotPass == undefined?sendJson.push({fieldEn:v.fieldEn,isSure:v.isSure}):sendJson.push({fieldEn:v.fieldEn,isSure:v.isSure,needExamineDataNotPass:v.needExamineDataNotPass})
        }
      })
      let params = {
        id:this.show.order.id,
        type:type,
        sendJson:JSON.stringify(sendJson)
      }
      get('ordersSortOutExamineSub',params,res=>{
        if(res.code == 200){
           Message.success('提交成功');
          this.show.reviewDialog = false;
          this.getData()
        }
      })
    },
    //订单审核页面初始化 
    reviewOrder(id){
      let params = {id};
      get("ordersSortOutExaminePage", params, res => {
        this.show.reviewDialog = true
        this.show.order = res.data.order;
        this.online.needJson = res.data.ordersSortOut.needJson;
        let oldJson = [];
        //如果是第二次审核，重新处理oldJson
        if (Array.isArray(res.data.ordersSortOut.sortOutJson)) {
            oldJson = []
          let needJson = res.data.ordersSortOut.needJson;
          let sortOutJson = res.data.ordersSortOut.sortOutJson;
          res.data.ordersSortOut.oldJson.map((v,index)=>{
            for(let i=0;i<res.data.ordersSortOut.needJson.length;i++){
              if(res.data.ordersSortOut.needJson[i].fieldEn==v.fieldEn){
                if(res.data.ordersSortOut.needJson[i].isSure==1){
                    if (Array.isArray(v["value"])) {
                        let _child = [];
                        v["value"].map(val => {
                        _child.push({ value: val, isSure: '1' });
                        });
                        oldJson.push({
                        fieldEn: v.fieldEn,
                        fieldCh: v.fieldCh,
                        isSure: 1,
                        title: "通过",
                        colour: "success",
                        isCanChoose: false,
                        _child: _child
                        });
                    } else {
                        oldJson.push({
                        fieldEn: v.fieldEn,
                        fieldCh: v.fieldCh,
                        isSure: '1',
                        value: v.value,
                        isCanChoose: false,
                        title: "通过",
                        colour: "success"
                        });
                    }
                }else{
                     if (Array.isArray(v["value"])) {
                        let _child = [];
                        v["value"].map(val => {
                            _child.push({ value: val, isSure: '1' });
                        });
                        sortOutJson.map(item=>{
                            if(v.fieldEn == item.fieldEn){
                                item.value.map(item1=>{
                                   _child.map(item2=>{
                                      if(item1 == item2.value){item2.isSure = 0} 
                                   })
                                })
                            }
                        })
                        oldJson.push({
                            fieldEn:v.fieldEn,
                            fieldCh:v.fieldCh,
                            isSure:0,
                            title:'请选择',
                            colour:'primary',
                            isCanChoose:false,
                            _child:_child
                        })
                    } else {
                        oldJson.push({
                        fieldEn: v.fieldEn,
                        fieldCh: v.fieldCh,
                        isSure: 0,
                        value: v.value,
                        isCanChoose: false,
                        title: "请选择",
                        colour: "primary"
                        });
                    }
                }
              }
            }
          })
        }else{
            oldJson = []
           res.data.ordersSortOut.oldJson.map(v => {
            if (Array.isArray(v["value"])) {
                let _child = [];
                v["value"].map(val => {
                _child.push({ value: val, isSure: 0 });
                });
                oldJson.push({
                fieldEn: v.fieldEn,
                fieldCh: v.fieldCh,
                isSure: 0,
                title: "请选择",
                colour: "primary",
                isCanChoose: false,
                _child: _child
                });
            } else {
                oldJson.push({
                fieldEn: v.fieldEn,
                fieldCh: v.fieldCh,
                isSure: 0,
                value: v.value,
                isCanChoose: false,
                title: "请选择",
                colour: "primary"
                });
            }
            }); 
        }
        this.show.oldJson = oldJson;
        this.online.sortOutJson = res.data.ordersSortOut.sortOutJson;
      });

      function getNewOldJson(oldJson,needJson,sortOutJson){
        let newOldJson=[]
        needJson.map((v)=>{
          for(let i=0;i<oldJson.length;i++){
            if(oldJson[i].fieldEn==v.fieldEn){
              if(v.isSure==-1){
                newOldJson.push(oldJson[i])
              }
            }
          }
        })
        sortOutJson.map(v=>{
          let sign=0
          for(let i=0;i<newOldJson.length;i++){
            if(newOldJson[i].fieldEn==v.fieldEn){
                sign=1
                if(Array.isArray(v['value'])){
                  if(!Array.isArray(v['value'])){
                     Message.error('程序错误:'+v['fieldEn']+'必须是数组');
                  }
                  let _child=[]
                  v['value'].map(val=>{
                    _child.push({isSure:0,value:val})
                  })
                  newOldJson[i]['_child']=_child
                }else{
                  if(Array.isArray(v['value'])){
                     Message.error('程序错误:'+v['fieldEn']+'必须不能是数组');
                  }
                  newOldJson[i]['value']=v.value;
                }
            }
          }
          if(sign==0){
             Message.error('程序错误:'+v['fieldEn']+'的数据不存在于newOldJson');
            return
          }
        })
        return newOldJson;
      }
    },
      radioChange(name,key=null){
      this.show.reasonData.indexs = [name,key];
      if(key!=null){
        /*
        1.全部没选择时：请选择
        2.只要有一个不通过时：不通过
        3.只有全部是通过时，通过
        */
        let isSure=null
        let type=[1,-1,-1,1];//0是否全部没选择，1是否有不通过，2是否全部通过,3是否全部选择
        this.show.oldJson[name]._child.map((v,k)=>{
          if(v.isSure==-1||v.isSure=='-1'){
            type[1]=1                 //是否有不通过，是
            type[2]=-1                //是否全部通过，否
            isSure=-1
          }
          if(v.isSure==0||v.isSure=='0'){
            type[3]=-1                //是否全部选择，否
          }else{
            type[0]=-1                //是否全部没选择，否
          }
          if(v.isSure==1||v.isSure=='1'){
            type[2]=1                 //是否全部通过，是
          }
        })
        if(type[1]==1){
          type[2]=-1
        }
        if(type[0]==1){                //是否全部没选择，是
          type[3]=-1
        }
        if(type[3]==1){
          this.show.oldJson[name]['isCanChoose']=true
        }
        if(isSure==null){
          if(type[2]==1){
            isSure=1
          }else{
            isSure=0
          }
        }
        this.show.oldJson[name]['title']=this.getTitle(isSure)
        this.show.oldJson[name]['colour']=this.getColour(isSure)
        this.show.oldJson[name]['isSure']=isSure
        // 多图情况下
        this.show.oldJson[name]._child[key]['isSure'] == -1?this.show.dialogs = true:this.show.dialogs = false
        this.show.reasonClickList = this.show.oldJson[name]._child[key].needExamineDataNotPass;
        this.show.reasonData.picNo = Number(key)+1;
        this.show.reasonData.value = this.show.oldJson[name]._child[key].value;
      }else{
        // 这里是单图的情况下
        this.show.oldJson[name]['isSure'] == '-1'?this.show.dialogs = true:this.show.dialogs = false
        this.show.oldJson[name]['title']=this.getTitle(this.show.oldJson[name]['isSure'])
        if(this.show.oldJson[name].needExamineDataNotPass){
          this.show.reasonClickList = this.show.oldJson[name].needExamineDataNotPass;
        }
        this.show.oldJson[name]['colour']=this.getColour(this.show. oldJson[name]['isSure'])
        this.show.reasonData.value = this.show.oldJson[name].value;
        this.show.reasonData.picNo = '';
      }
      this.show.reasonData.isCheck = false;
      this.show.message = '';
      this.show.reasonData.fieldCh = this.show.oldJson[name].fieldCh;
      this.show.reasonData.fieldEn = this.show.oldJson[name].fieldEn;
      if(this.show.dialogs){
        this.getReasonList()  
      }
      this.$forceUpdate()
    },
    reasonChange(val){
      this.show.reasonData.isCheck = val;
      this.show.message = '';
    },
    reasonListShows(val){
      this.show.isReasonListShow = true;
      this.show.reasonListDialog = val;
    },
    onBeforeClose(action){
      if(action == 'confirm'){
        if(this.show.reasonClickList == undefined || this.show.reasonClickList.length == 0 ){
           Message.error('不通过理由不能为空')
        }else{
          // 这里是单图
          let parent = this.show.reasonData.indexs[0];
          let child = this.show.reasonData.indexs[1];
          if(child == null){
            this.show.reasonClickList ==undefined?console.log(1):this.show.oldJson[parent].needExamineDataNotPass = this.show.reasonClickList; 
          }else{       //这里是多图
            this.show.reasonClickList ==undefined?'':this.show.oldJson[parent]._child[child].needExamineDataNotPass  = this.show.reasonClickList;  
          }
          this.show.reasonList = [];
          this.show.selectColumn = false;
          this.show.dialogs = false;
        }
      }else{
        this.show.dialogs = false; 

        }  
    },
      getTitle(isSure){
        switch(isSure){
          case -1:
            return '不通过'
          case 0:
            return '请选择'
          case 1:
            return '通过'
          case '-1':
            return '不通过'
          case '0':
            return '请选择'
          case '1':
            return '通过'
        }
      },
      getColour(isSure){
        switch(isSure){
          case -1:
            return 'danger'
          case 0:
            return 'primary'
          case 1:
            return 'success'
          case '-1':
            return 'danger'
          case '0':
            return 'primary'
          case '1':
            return 'success'
        }
      },
      isShowcondition(){
      let val = '1';
      let parent = this.show.reasonData.indexs[0];
      let child = this.show.reasonData.indexs[1]
      if(this.show.reasonData.indexs[1]== null){
        this.show.oldJson[parent]['title']=this.getTitle(val)
        this.show.oldJson[parent]['colour']=this.getColour(val)
        this.show.oldJson[parent]['isSure']=val
      }else{
        this.show.oldJson[parent]._child[child]['title']=this.getTitle(val)
        this.show.oldJson[parent]._child[child]['title']=this.getColour(val)
        this.show.oldJson[parent]._child[child]['isSure']=val
      }
     },
    // 填写理由
       reasonMsg(){
      var len = this.show.reasonList.filter(item => item.title == this.show.message);
      if(len.length>0){
         Message.error('已有相同原因');  
      }else{
      let params = {
        fieldEn:this.show.reasonData.fieldEn,
        title:this.show.message,
      }
      if(this.show.message == ''){
         Message.error('原因不能为空')  
      }else{
      this.show.reasonData.indexs[1] == null ? params.type = 1 : params.type = 2;
      get('addNotPass',params,(res) => {
        if(res.code == 200){
          this.$message.success('添加成功');  
          this.show.reasonData.isCheck = false
          this.show.message = '';
        }else{
             Message.error('退回原因最多只能有8个')
        }
      })
      }
      }
    },
    // 取消审核  状态通过
    examineCancel(){
      this.show.dialogs = false;
      this.isShowcondition()
      this.show.reasonClickList = []
      this.show.reasonList = [];
      this.show.selectColumn = false;
      this.show.child_dialogs = false;
    },
    // 获取不通过原因列表
   getReasonList(){
      let params = { 
        fieldEn:this.show.reasonData['fieldEn'],
        type:this.show.reasonData.indexs[1]==null?1:2,
      }
      get('getFieldEnNotPass',params,(res) => {
        if(res.code==200){
          this.show.reasonList  = res.data
          this.show.reasonList.push({'title':'其他原因','id':'NA'}) 
          this.$forceUpdate()
        }else{
           Message.error('无原因可选,请先填写')
          this.show.reasonData.isCheck = true;
        }
      }) 
    },
    pdfLocation(val){
      location.href = val;
    },
   handleChange(val){
      let other = val.filter(item => item.id == 'NA');
      if(other.length>0){
        this.show.reasonData.isCheck = true;
        this.$refs.mySelect.handleClose()
      }else{
        this.show.reasonData.isCheck = false;
      }
      this.show.reasonClickList = val.filter(item => item.id != 'NA');
    },
    showChoose(index){
      this.show.reasonData.indexs = [index,null];
      //记住当前选中
      this.show.oldJson.map((v,k)=>{
        if(k==index){
          if(v.isCanChoose){
            this.action.isShowPopup = true;
          }else{
            if(v._child != undefined){
               Message.error('选项全部选择后 才可以点击该按钮')  
              return false
            }else{
               Message.error('单图不可点击该按钮')    
              return false;
            }
          }
        }
      })
      this.action.clickIndex = index;
    },
    onConfirm(val){
      let color = '';
      val == '通过'? color = 'success': color = 'danger';
      if(val == '不通过'){
        this.show.dialogs = true; 
        this.show.reasonClickList = this.show.oldJson[this.action.clickIndex].needExamineDataNotPass; 
      }
      this.getReasonList()  
      this.show.oldJson[this.action.clickIndex]['title'] = val;
      this.show.oldJson[this.action.clickIndex]['isSure'] = val=='通过'?1:-1;
      this.show.oldJson[this.action.clickIndex]['colour'] = color;
      this.show.selectColumn = true;
      this.action.isShowPopup = false;
      this.show.reasonList.push({'title':'其他原因','id':'NA'});
    },
    onCancel(){
       this.action.isShowPopup = false;
    },
    selectFocus(){
      this.getReasonList()
      this.show.reasonData.isCheck = false;
    },
    ///////////////////////////订单审核  end

    getBigImg(value){
      this.show.imgList.bigImgUrl = value
      this.show.imgList.showBigImg = true
    },
    tabchange(val){
      this.show.args.sort_str = val.prop
      this.show.args.sort_order = val.order=='ascending'?'asc':'desc'
      this.getData(this.show.args)
    },
    download(){},
    //------------------------------------------------上传文件
    /*
    处理中  上传oa截图 报销凭证号  。。。
    */
  
    //提交报销凭证号按钮
    onSubmitBx(){
      if(this.show.rmb_voucher.trim() == "") {
         Message.error("请先填写报销凭证号");
        return;
      }
      this.submitPostBx();
    },
    //提交报销凭证号
    submitPostBx() {
        let params = {
            rmbVoucher:this.show.rmb_voucher,
            id:this.post.id
        }
       get("upRmbVoucher",params, res => {
          if (res.code === 200) {
            this. value=''
            this.getData()
            this.get()
            this.show.showbxnum = false
          }
        });
    },
    // 文件上传后的钩子函数
    handleSuccess(res, file){
      this.show.fileList.push(file)
      this.show.imgList.imageUrl = URL.createObjectURL(file.raw);
      this.show.imgList.srcList[0] = this.show.imgList.imageUrl
      switch (this.show.process.wh) {
        case 'qz':
          this.show.params.signFile = res.data;
        break;
        case 'oa':
          this.show.params.oaFile = res.data;
        break;
        default:
        break;
        }
    },
    handleProgress(){
       Message.success('图片上传中 请稍候')
    },
    uploadFileHttp(file){
      let upfile = new FormData();
      upfile.append("file", file.file);
      Axios.post(config.get('e_url')+'v1000_upload',upfile)
      .then(res =>{
          let ret = res.data
          if(ret.code == 200) {
            this.show.imgList.imageUrl = ret.data
            this.show.fileList.push(ret.data)
            this.show.imgList.srcList[0] = this.show.imgList.imageUrl
            switch (this.show.process.wh) {
                case 'qz':
                this.show.params.signFile = ret.data;
                break;
                case 'oa':
                this.show.params.oaFile = ret.data;
                break;
                default:
                break;
            }
          }
      })
    },
    //上传文件
    submitPost() {
      if (this.show.params) {
        this.show.params.id = this.post.id;
        let url = 'http://v1-e.xgwl.net.cn/v1000_upload';
        this.show.process.wh == 'qz'?url = 'upSignFile':url = 'upOsFile';
        get(url,this.show.params, res => {
          if (res.code === 200) {
             Message.success("上传成功！");
            this.show.params={}
            this.show.fileList = []
            this.getData()
            this.get()
            this.show.showUpFile = false
            this.delImg()
          }
        });
      }else{
         Message.success(this.show.process.title);
      }
    },
    // 撤回文件
    withdrawFile(wh){
      var url;
      var msg;
        switch(wh){
          case 'qz':
            url = 'withdrawSignFile';  
            msg = '签字文件'
          break;
          case 'oa':
            url = 'withdrawOaFile';
            msg = 'oa截图'
          break;
          case 'card':
            url = 'withdrawRmbVoucher',
            msg = '报销凭证号'
          break;
        }  
      Dialog.confirm({
        title: '撤回文件',
        message: '是否撤回'+msg,
        className:'signDialog'
        }).then(() => {
        let params = {
          id:this.online.detailData.id
        }
        get(url,params,(res) => {
          if(res.code == 200){
          Toast.success('撤回成功');
          this.show.rmb_voucher = '';
          this.get(false);  
          this.getData()
          switch(wh){
            case 'qz':
              this.show.process.bz = 0;
            break;
            case 'oa':
              this.show.process.bz = 1;
            break;
            case 'card':
              this.show.process.bz = 2;
            break;  
          }
          this.$forceUpdate();
          }else{
              if(wh == 'oa'){
                  this.show.process.bz = 1
              }
            let num = res.data.indexOf(':');
             Message.error(res.data.slice(num+1)); 
          }  
        })
        })
        .catch(() => {
           Message.error('您已取消撤回')
        });
    },
    upFile() {

      var wh;
      if (this.show.process.xm == 3 && this.show.process.bz == 0) {
        wh = "qz";
      }
      if (this.show.process.xm == 3 && this.show.process.bz == 1) {
        wh = "oa";
      }
      if (this.show.process.xm == 3 && this.show.process.bz == 2) {
        wh = "bx";
      }
      if (this.show.process.xm == 4 && this.show.process.bz == 1) {
        wh = "oa";
      }
      if (this.show.process.xm == 4 && this.show.process.bz == 0) {
        wh = "oa";
      }
      if (this.show.process.xm == 4 && this.show.process.bz == 2) {
        wh = "bx";
      }
      this.show.process.wh = wh
      switch (wh) {
        case "qz":
        case "oa":
          if(wh=='qz'){
            this.show.process.title='上传签字文件'
          }else{
            this.show.process.title='上传oa截图'
          }
          this.show.showUpFile = true

          break;
        case "bx":
          this.show.showbxnum = true
          break;
        default:
          break;
      }
       this.delImg()
    },
    //上传文件按钮
    onSubmit() {
      if (!this.show.fileList.length) {
         Message.error("请先上传文件");
        return;
      }
      this.submitPost();
    },
    // 失去焦点
    selectBlur(){
        if(this.show.reasonClickList == undefined){
            this.show.reasonData.isCheck = true
        }
    },
    // 清空文件状态
    delImg(){
      this.show.imgList.imageUrl = '';
      this.imgList = [];
    },
    //获取订单详情
    get(flag = true) {
      let params = {
        id: this.post.id,
      };
      get('ordersDetail',params,(res) => {
        if (res.code == 200) {
            console.log('res',res.data)
          this.online.detailData = res.data;
          this.post.id = res.data.id;
          this.online.detailData.statusName = this.getStaus(res.data.status)
          this.show.order_detail = JSON.parse(res.data.expenseCateCompanyPriceJson);
          this.show.detailDialog = true
          this.show.ddStatus = this.online.detailData.statuss[this.online.detailData.statuss.length - 1].describe
          this.show.process.lx= this.online.detailData.status;
          var id = this.online.detailData.statuss[this.online.detailData.statuss.length - 1].status_id;
          console.log('id',id)
          if(flag){
            this.online.detailData.statuss.length > 0 && id == 3 ? (this.show.process.bz = 0) : "";
            this.online.detailData.statuss.length > 0 && id == 7 ? (this.online.detailData.sign_file != null ?this.online.detailData.sign_file.length != 0:this.online.detailData.sign_file != null) ? (this.show.process.bz = 1) :this.show.process.bz = 0:'';
            this.online.detailData.statuss.length > 0 && (id == 6)?(this.online.detailData.oa_img != null ?this.online.detailData.oa_img.length != 0:this.online.detailData.oa_img != null) ? (this.show.process.bz = 2) :this.show.process.bz = 1:'';
            this.online.detailData.statuss.length > 0 && (id == 8)?(this.online.detailData.rmb_voucher != null ?this.online.detailData.rmb_voucher.length != 0:this.online.detailData.rmb_voucher != null) ? (this.show.process.bz = 3) :this.show.process.bz = 2:'';
            if((this.online.detailData.rmb_voucher != null ? this.online.detailData.rmb_voucher.length == 0:this.online.detailData.rmb_voucher == null) && (this.online.detailData.oa_img != null ?this.online.detailData.oa_img.length == 0:this.online.detailData.oa_img == null) && (this.online.detailData.sign_file != null ?this.online.detailData.sign_file.length == 0:this.online.detailData.sign_file == null)){
              this.show.process.bz = 0;  
            }
          }
         this.online.detailData.statuss.length > 0  && (this.show.process.xm == 4) && (id == 6 || id == 8)?(this.online.detailData.oa_img != null ?this.online.detailData.oa_img.length != 0:this.online.detailData.oa_img != null) ? (this.show.process.bz = 2) :this.show.process.bz = 0:'';
    
         console.log(this.show.process.bz)
        }
        this.show.process.xm = this.online.detailData.service_project;
        console.log(this.show.process.xm)
        if (this.online.detailData.status != 1) {
          var jdIndex = this.online.detailData.statuss.findIndex((item) => {
            return item.status_id == 3;
          });
          this.online.detailData.statuss[jdIndex]?this.show.jdDate = this.online.detailData.statuss[jdIndex]['created_at']:'';
        }
      });
    },
    //详情按钮-------------------------------------------------------------------
    truebc() {
      let params = {
        id: this.post.id,
      };
      get('confirmCompletion',params,(res) => {
        if(res.code == 200){
           Message.success('订单已完成 等待用户确认');
          this.getData()
          this.show.detailDialog = false
        }else{
           Message.error(res.data) 
        }
      })
    },
    signReason(action,done){
      if(action == 'confirm'){
        if(this.show.message1 == ''){
           Message.error('退单理由不能为空')  
          done(false)
        }else{
          let params = {
            id:this.post.id,
            remark:this.show.message1m   
          }
          get('applyChargeback',params,(res) => {
            if(res.code == 200){
              done()
              Toast.success('退单成功')
            }else{
              done()
               Message.error(res.data)
            } 
          })  
        }
      }
      else{
          done()
      }
  },
  applySign(action,done){
    if(action == 'confirm'){
    if(this.show.order_sign.isSign == null){
       Message.error('必须选择通过或不通过')  
      done(false)
    }else{
      let params = {
        id:this.post.id,
        type:this.show.order_sign.isSign,
      }
     if(this.show.order_sign.isSign == -1 && this.show.order_sign.msg.length == 0){
        Message.error('退回理由不能为空')
       done(false)
     }else{
     this.show.order_sign.isSign == 1?'':params.remark = this.show.order_sign.msg
      get('chargebackExamine',params,(res) => {
        if(res.code == 200){
           Message.success('审核成功');
          this.show.detailDialog = false
          this.getData();
        }else{
           Message.error(res.data);
        }
        done()
      })  
    }
    }
    }
  },
      onSubmitBack(){
      if ((this.show.order_sign.backvalue.trim() == "")) {
         Message.error("请先填写退回理由");
      }else{
        let params = {
          remark:this.show.order_sign.backvalue,
          id:this.online.detailData.id
        }
        get('applyChargeback',params,(res) => {
          if(res.code == 200){
             Message.success('订单退回成功');
            this.show.showback = false;
            this.show.detailDialog = false;
            this.show.dia
            this.get()
            this.getData()  
          }  
        })
      }
    },
    //接单
    pickOrder() {
      if (this.smrz) {
        let params = {
          // repOrders
          id: this.post.id,
        };
        get('acceptOrders',params,res=>{
            if (res.code == 200) {
              Dialog.alert({
                title: "接单成功",
                message: `报销天数:${this.online.detailData.service_time}天;  超时一天:该订单将无收益;   超时两天:扣费50元;    超时三天:该订单将重新指派代报员;`,
              }).then(() => {
                this.getHeadCount()
                this.getData()
                this.show.detailDialog = false
                //this.get()
              });
            } else {
               Message.error("接单失败");
            }
        })
      } else {
        Dialog.alert({
          title: "提示",
          message: `请先进行实名认证`,
        }).then(() => {
          this.$router.push("/authentication");
        });
      }
    },
    //头部选择
    topClick(value){
      this.show.args.p = 1
      this.show.header.showTitle = value.title
      this.online.dataList = []; 
      this.show.args.type = value.type
      this.show.search.searchData = ''
      this.getData(this.show.args) 
    },
    handleCurrentChange(newPage) {
        this.show.args.p = newPage;
        this.getData(this.show.args);
    },
    //搜索按钮
    searchBtn(){
      if (!this.show.search.searchData) {
        this.getData()
        return
      }
     this.show.args.p = 1
      switch (this.show.search.searchType) {
        case 'order_number':
          this.show.args.order_number = this.show.search.searchData
          break;
        case 'rmb_voucher':
          this.show.args.rmb_voucher = this.show.search.searchData
          break;
      }
      this.getData(this.show.args)
    },
    //退出登录
    logOut() {
      this.$store.commit("delUser");
      this.$store.commit("delToken");
      sessionStorage.removeItem("store");
      sessionStorage.removeItem("token");
       Message.success("退出成功");
      this.$router.push("/login");
    },
    //显示修改手机号弹窗
    editPhpto() {
      this.$refs["editAvatar"].show();
    },
    //获取用户数据
    getUserData() {
      getMyInfo().then((res) => {
        this.$store.commit("setUser", res.data);
      });
    },
    getStaus(value){
     switch (value) {
    case 1:
      return "待接单";
    case 2:
      return "处理中";
    case 3:
      return "用户待确认";
    case 4:
      return "已完成";
    case 5:
      return "待付款";
    case 6:
      return "代报员退回";
    case 7:
      return "补充资料待确认";
    case 8:
      return "失效";
    case 9:
      return "已取消";
    case 10:
      return "检查报销资料中";
    case 11:
      return "报销资料需补充信息";
    case 12:
      return "待代报员确认自已工作结果是否正确";
    case 13:
      return "退款订单";
  }  
  },
    //获取订单数据
    getData(args) {
      this.show.tabload = true
      let params = {};
      this.show.args.p == '' || undefined ?'':params.p = this.show.args.p;
      params.limit = 10;
      this.show.args.type == '' ?'':params.type = this.show.args.type;
      this.show.args.sort_str == '' ?'':params.sort_str = this.show.args.sort_str;
      this.show.args.sort_order == '' ?'':params.sort_order = this.show.args.sort_order;
      this.show.args.order_number == '' ?'':params.order_number = this.show.args.order_number;
      this.show.args.rmb_voucher == '' ?'':params.rmb_voucher = this.show.args.rmb_voucher;
      get("ordersList",params,(res) => {
        this.show.tabload = false
        if (res.code === 200) {
          // 获取订单状态正常的订单
          this.show.dataCount = res.data.count
          this.online.dataList = res.data._list;
          this.show.args.order_number = '';
          this.show.args.rmb_voucher = '';
        }
      });
    },
    //订单详情弹窗
    goDetails(item) {
      this.post.id = item.id;
      this.get()
    },
    //  获取头部总数
     getHeadCount(){
        get('ordersCounts',{},res=>{
            console.log(res)
            this.show.header.typeList[0].num = res.data.a
            this.show.header.typeList[1].num = res.data.b
            this.show.header.typeList[2].num = res.data.c
        })
    },
    handleBXClose(){
        this.show.showbxnum = false
    }
  },
  deactivated() {
    this.$destroy(true); //销毁组件
  },
  filters:{
    paytype(value){
      switch (value) {
        case '1':
          return '公务卡'
          break;
        case '2':
          return '工资卡'
          break;
        default:
      }
    },
    fs(value){
      if (value.fieldEn == 'payType') {
        if (value.value == '1') {
          return "公务卡"
        }else{
          return '工资卡'
        }
      }
      if (value.fieldEn == 'isOtherPay') {
        if (value.value == '1') {
          return "他人"
        }else{
          return '自己'
        }
      }
      if (value.fieldEn == 'payNo' || value.fieldEn == 'payName') {
        return value.value
      }
      if (value.fieldEn == "isOfficialCard") {
        return value.value == "1" ? '是' : "否"
      }
    },
    isother(value){
      switch (value) {
        case '1':
          return '他人'
          break;
        case '-1':
          return '自己'
          break;
        default:
          break;
      }
    },
    record(value){
      switch (value) {
        case '1':
          return '代报员原因'
          break;
        case '-1':
            return '客户原因'
            break;
        default:
          break;
      }
    },
    isCs(value){
      var a = value<1?'超时':value
      return a
    },
  },
  created() {
    this.getHeadCount()
    let params = {
      p:1,
      limit:10
    };
    get("moneyBagList",params, res => {
      if (res.code === 200) {
        this.show.header.coin = res.data.errands_info.financeJson.balance
      }
    })
  },
  mounted() {
    this.getUserData();
    this.getData()
    let isSmrzOver = sessionStorage.getItem("isSmrzOver");
    if (isSmrzOver == "false") {
      Dialog.confirm({
        title: "提示",
        message:
          "您还没有实名认证，这会影响到您的后续操作，请尽快进行实名认证。",
        confirmButtonText: "立即认证",
        cancelButtonText: "暂不认证",
      })
        .then(() => {
          this.$router.push("/authentication");
          sessionStorage.setItem("isSmrzOver", true);
        })
        .catch(() => {
          sessionStorage.setItem("isSmrzOver", true);
        });
    }
  },

  computed: {
    ordermsg2(){
      var a = []
      var b = []
      for (const key in this.online.detailData.ordersExpenseCateJson) {
        if (this.online.detailData.ordersExpenseCateJson[key].type == "file") {
          a.push(this.online.detailData.ordersExpenseCateJson[key])
        }else{
          b.push(this.online.detailData.ordersExpenseCateJson[key])
        }
      }
      return [a,b]
    },
    photo() {
      return (
        
        this.$store.state.user.photo
      );
    },
    nickname() {
      return this.$store.state.user.nickname;
    },
    smrz() {
      return sessionStorage.getItem('isSmrzOver')
    },
  },
};
</script>

<style lang="less" >
.steps_box{
  position: relative;
  text-align: left;
  margin: 30px 0 10px 20px;
  span{
    display: inline-block;
    vertical-align: middle;
  }
  .outside{
      vertical-align: middle;
      box-sizing: content-box;
      display: inline-block;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      border: 1px #006CFF solid;
      margin-right: 10px;
  }
  .inside{
      box-sizing: content-box;
      display: block;
      margin: 4px 4px;
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #006CFF;
  }
}
.steps_box::after{
  content: "";
  display: block;
  width: 2px;
  height: 54px;
  background: #006CFF;
  position: absolute;
  top: 30px;
  left: 7px;
}
.steps_box:last-child::after{
  width: 0;
  height: 0;
}
.supplement {
  width: 50% !important;
  margin: auto !important;
  box-sizing: border-box;
  &-form {
    margin-top: 20px;
    .van-cell {
      margin-bottom: 15px;
    }
  }
  .van-submit-bar {
    bottom: 20px;
  }
  &-btn {
    width: 50%;
    box-sizing: border-box;
    padding: 0 15px;
    bottom: 30%;
    position: inherit !important;
    margin-top: 100px;
  }
}
.step-title span{
  font-size: 14px;
}
.step-info{
  text-align: left;
}
.step-info span{
  font-size: 12px;
}
.van-step__circle-container{
  width: 17px;
  height: 17px;
}
.orderInfo-content .steps-box /deep/ .van-steps .activeIcon{
  padding: 4px !important;
}
.activeIcon{
  height: 17px !important;
  width: 17px !important;
  border: 1px solid #068eff !important;
  div{
    width: 7px !important;
    height: 7px !important;
    // border: 1px !important;
  }
}
.van-step__line{
  height: 56px !important ;
  margin: auto !important;
}
.van-cell__title{
  text-align: left;
}
.el-dialog{
  margin-top: 20px !important;
}
.el-dialog_body{
  margin-top:0 !important ;
}
.nav-bar .bottom{
  line-height: 40px !important;
  padding: 0 21px !important;
  height: 40px;
  text-align: center;
}

.maxdiv{
    width: 95%;
    margin:auto;
    height: auto;
    box-shadow: 1px 1px 10px #ccc,-1px -1px 10px #ccc;
    padding-bottom: 20px;
    .top_main{
        border-bottom: 1px solid #ccc;
        height: 40px;
        background: #F5F7FA;
        margin-bottom: 30px;
        .top_main_list{
          height: 100%;
          box-sizing: border-box;
            cursor: pointer;
            padding: 10px 22px;
            color: #909399;
            transition: .2s;
            font-size: 14px;
            line-height: 40px;
            &:hover{
                color: #409eff;
            }
            &:nth-child(1){
                border-left:none;
            }
        }
        .clicked_top{
            color: #409eff;
            background: #fff;
            border-left:1px solid #ccc ;
            border-right:1px solid #ccc ;
        }
    }
}
.user_msg{
  display: flex;
  top: 0;
  left: 0;
  a{
    background:#fff;
    line-height: 52px;
    padding: 0 30px;
    float: left;
  }
}
.el-loading-mask{
  z-index: 1 !important;
}
.nickname{
  position: relative;
  &:hover{
    .cz_list{
      max-height: 500px;
    }
  }
  .cz_list{
    z-index: 9999;
    transition: .4s;
    position: absolute;
    width: 100px;
    top: 65px;
    left: -18px;
    color: #000;
    max-height: 0px;
    overflow: hidden;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
    border: 1px solid #ebeef5;
    background-color: #fff;
    li{
      height: 30px;
      text-align: center;
      width: 100%;
      padding: 0;
      line-height: 30px;
      font-weight: 400;
      font-size: 14px;
      &:hover{
        background: #ecf5ff;
        color: #66b1ff;
      }
    }
  }
}
.home-content{
  width: 80%;
  margin: auto;
}
.main {
  padding-bottom: 50px;
}
.order-header {
  width: 100%;
  padding: 0 0.4rem;
  height: 60px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  font-weight: 700;
  color: #353535;
  background-color: #fff;
  z-index: 2;

  > span:nth-child(1) {
    display: flex;
    align-items: center;

    > span:nth-child(1) {
      display: inline-block;
      width: 0.933333rem;
      height: 0.933333rem;

      > img {
        width: 100%;
        height: 100%;
      }
    }

    > span:nth-child(2) {
      margin-left: 0.266667rem;
      font-weight: 700;
      font-size: 0.533333rem;
    }
  }

  > span:nth-child(2) {
    display: inline-block;
    width: 21.5px;
    height: 20.5px;

    > img {
      width: 100%;
      height: 100%;
    }
  }
}

.user_msg {
  width: 100%;
  height: 65px;
  background: #4259f0;
  box-sizing: border-box;
  padding: 0 2.5%;
  line-height: 65px;
  color: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1500;
  .user_nameimg {
    position: absolute;
    right: 2.5%;
    display: flex;
    cursor: pointer;
    margin-left: 20px;
    .van-image {
      margin: 10px 10px;
      height: 40px;
      width: 40px !important;
    }
    // }
    span {
      font-size: 16px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
    }
  }

  .user_money {
    position: absolute;
    right: calc(~'2.5% + 140px');
    display: flex;
    margin-right: 15px;
    font-size: 14px;
    font-family: PingFang-SC-Regular, PingFang-SC;
    font-weight: 400;

    .money_num {
      margin-left: 10px;
      font-size: 20px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
    }
  }
}
a:link,
a:visited {
  text-decoration: underline;
  color: #0016ff;
}
.nav-bar {
  width: 100%;
  background-color: #fff;
  position: relative;
  z-index: 3000;
  margin-bottom: 10px;
  .bottom {
    padding: 0 0.4rem;
    box-sizing: border-box;
    line-height: 1.333333rem;
    font-size: 20px;
    z-index: 1;
    text-align: center;
    > span {
      &:nth-child(1) {
        height: 1.333333rem;
        float: left;
        text-align: center;
        font-weight: 700;
        i {
          line-height: 1.333333rem;
        }
      }
      &:nth-child(2) {
        text-align: center;
        font-weight: 700;
      }
    }
  }
}
.order_jiebtn {
  div {
    width: 60%;
    height: 45px;
    line-height: 45px;
    margin-top: 15px;
    background: #0016ff;
    border-radius: 22.5px;
  }
}
.order_btn {
  height: auto;
  background: #fff;
  line-height: 45px;
  font-size: 20px;
  position: relative;
  z-index: 1999;
  font-family: PingFang-SC-Medium, PingFang-SC;
  font-weight: 500;
  color: #ffffff;
  text-align: center;
  bottom: 0;
  div{
    width: 60%;
    margin: auto;
  }
}
.order_qxbtn {
  div {
    width: 60%;
    height: 45px;
    line-height: 45px;
    margin-top: 15px;
    background: #0016ff;
    border:1px solid #0016ff;
    border-radius: 22.5px;
  }
  div:nth-child(1) {
    background: #fff;
    color: #0016ff;
  }
}
.withdraw-btn{
  border:1px solid #0016ff;
}
.order_backbtn {
  margin-bottom: 60px;
  div {
    width: 100%;
    height: 45px;
    line-height: 45px;
    border: 1px solid #0016ff;
    margin-top: 15px;
    background: #0016ff;
  }
}

.orderInfo {
  padding-bottom: 10px;
  &-content {
    .steps-box {
      /deep/.van-steps {
        .van-hairline.van-step.van-step--vertical.van-step--finish {
          .van-step__line {
            background-color: #1996ff;
          }
        }

        .van-hairline.van-step.van-step--vertical:last-child {
          .van-step__line {
            display: none;
          }
        }

        .van-step__circle-container {
          z-index: 1;
          background-color: #fff;
        }

        // 激活的图标
        .activeIcon {
          padding: 0.053333rem;
          box-sizing: border-box;
          width: 0.293333rem;
          height: 0.293333rem;
          border-radius: 50%;
          border: 0.026667rem solid #068eff;

          > div {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-color: #068eff;
          }
        }
        .step-title {
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 0.373333rem;
          font-weight: 700;
          color: #353535;
          .button {
            padding: 0 0.266667rem;
            font-size: 0.32rem;
            background-color: #c8c8c8;
            border-radius: 0.2rem;
            font-size: 0.32rem;
            height: 0.426667rem;
            line-height: 0.4rem;
            font-weight: 500;
          }
        }

        .step-info {
          color: #353535;
          font-size: 0.32rem;

          > div:nth-child(1) {
            display: flex;
            justify-content: space-between;
            line-height: 0.8rem;
          }
        }
      }
    }
  }
}
.van-popup{
  z-index:999999 !important;
}
.supplement{
  .order-info{}
  .order-data{
    .order-data-item{
      margin-bottom: 20px;
      .van-image{
        margin-right: 30px;
        box-shadow: 1px 1px 5px #888888;
      }
    }
  }
}
.supplement-button{
  width: 100%;
  box-sizing: border-box;
  padding: 0 15px;
  margin:8% 0;
}
.mt5{
  margin-bottom: 5px;
}
.van-picker{
  margin: 0;
}
.img-choose-warp{
  display: flex;
  justify-content:left;
  flex-wrap: wrap;
}
.flex-column{
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  padding:.2rem;
}
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 150px;
    height: 150px;
    line-height: 150px;
    text-align: center;
  }
  .avatar {
    width: 150px;
    height: 150px;
    display: block;
  }
.el-icon-plus:before {
    content: "\e6d9";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}
.upload-wrap{
  width:150px;
  height:150px;
  position: relative;
}
  /deep/ .select {
    z-index:2050 !important;
  }
  .van-button--primary{
    position: absolute !important;
    background:none !important;
    color:red !important;
    right: -15px !important;
    bottom: -5px !important;
  }
  .van-dialog{
    top:43%;
    z-index:2020 !important;
    width:420px !important;
    border:1px solid #ddd;
  }
  .van-field__word-limit {
    text-align:left !important;
  }
  .dialog-img-offset{
    padding-left:50px;
  }
  /deep/ .el-select .el-input .el-select__caret{
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }
.dialog{
  padding:10px 15px;
}
.column{
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
}
.dialog-title{
  font-size:14px;
  font-weight:bold;
  vertical-align: middle;
}
.dialog-img{
  display: flex;
  justify-content:flex-start;
  padding:10px 0;
  img{
    width:70px;
    height:70px;
  }
  .dialog-img-right{
    span{
      vertical-align: top;
      font-size: 13px;
      padding-left:5px;
    }
    p{
      font-size:13px;
      font-weight:100;
    }
  }
}
/deep/ .van-overlay{
  z-index:2020 !important
}
/deep/.van-field__left-icon {
  margin-right: 5px;
  position: absolute;
  bottom: 5px;
}
.el-input__icon{
  display: flex !important;
  justify-content: center !important; 
  align-items: center !important;  
}
.van-popup--bottom{
  width:35% !important;
  height:35% !important;
  left:50% !important;
  top:50% !important;
  transform:translate(-50%,-50%) !important;
}
  .van-tag{
    cursor: pointer !important;
} 
.btn-wrap{
  display: flex;
  justify-content: center;
  margin-top:20px;
  button{
    margin:0 10px;
  }
}
.error-img{
  width:80px;
  height:80px;
  background-size: cover;
  cursor: pointer;
}
</style>
<style lang="less">
  .select{
    z-index: 3000 !important;
  }
  .signDialog{
    z-index:2050 !important;
  }
  .van-dialog{
    z-index:2088 !important;
  }
  .van-radio-group--horizontal{
    justify-content: center;
  }
  .van-radio{
    padding:2px 6px;
  }
  .van-dialog__header{
    font-size:20px;
    font-weight:500;
  }
  .van-field__value{
    padding:0 10px;
  }
</style>
